﻿using Newtonsoft.Json;

namespace Bit.BlazorUI;

/// <summary>
/// As per documentation <a href="https://www.chartjs.org/docs/latest/axes/cartesian/#common-configuration">here (Chart.js)</a>.
/// </summary>
public abstract class BitChartCartesianAxis : BitChartAxis
{
    /// <summary>
    /// The type of axis this instance represents.
    /// <para>For js-interop/serialization purposes so Chart.js knows what axis to use.</para>
    /// </summary>
    public abstract BitChartAxisType Type { get; }

    /// <summary>
    /// The ID is used to link <see cref="BitChartLineDataset{T}"/>/<see cref="BitChartBarDataset{T}"/> and <see cref="BitChartCartesianAxis"/> together.
    /// Referenced in <see cref="BitChartLineDataset{T}.XAxisId"/> and <seealso cref="BitChartLineDataset{T}.YAxisId"/>
    /// (<see cref="BitChartBarDataset{T}.XAxisId"/> and <seealso cref="BitChartBarDataset{T}.YAxisId"/> respectively).
    /// </summary>
    [JsonProperty("id")]
    public string? ID { get; set; }

    /// <summary>
    /// Gets or sets the position of the axis in the chart.
    /// </summary>
    public BitChartPosition? Position { get; set; }

    /// <summary>
    /// If true, extra space is added to the both edges and the axis is scaled to fit into the chart area.
    /// This is set to true for a category scale in a bar chart by default.
    /// </summary>
    public bool? Offset { get; set; }

    /// <summary>
    /// Gets or sets the scale title configuration.
    /// </summary>
    public BitChartScaleLabel? ScaleLabel { get; set; }

    /// <summary>
    /// Defines options for the grid lines that run perpendicular to the axis.
    /// </summary>
    public BitChartGridLines? GridLines { get; set; }
}

/// <summary>
/// <see cref="BitChartCartesianAxis"/> which contains the ticks-subconfig.
/// </summary>
/// <typeparam name="TTicks"></typeparam>
public abstract class BitChartCartesianAxis<TTicks> : BitChartCartesianAxis where TTicks : BitChartCartesianTicks
{
    /// <summary>
    /// Defines options for the tick marks that are generated by the axis.
    /// </summary>
    public TTicks? Ticks { get; set; }
}
